<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>用户管理 - Spring Boot 3.x + MyBatis Plus 示例</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    <style>
        body {
            padding-top: 5rem;
        }
        .card {
            margin-bottom: 1.5rem;
        }
        .table-container {
            max-height: 600px;
            overflow-y: auto;
        }
        .footer {
            margin-top: 3rem;
            padding: 1.5rem 0;
            border-top: 1px solid #eaeaea;
        }
    </style>
</head>
<body>
    <nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
        <div class="container">
            <a class="navbar-brand" href="/mybatis-plus/">Spring Boot 3.x + MyBatis Plus 示例</a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav">
                    <li class="nav-item">
                        <a class="nav-link" href="/mybatis-plus/">首页</a>
                    </li>
                    <li class="nav-item active">
                        <a class="nav-link" href="#">用户管理</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" th:href="@{/swagger-ui.html}" target="_blank">API文档</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" th:href="@{/h2-console}" target="_blank">H2控制台</a>
                    </li>
                </ul>
            </div>
        </div>
    </nav>

    <main class="container">
        <div class="row">
            <div class="col-md-12">
                <div class="card">
                    <div class="card-header">
                        <div class="d-flex justify-content-between align-items-center">
                            <h4>用户管理</h4>
                            <a href="/mybatis-plus/user-management/add" class="btn btn-primary">添加用户</a>
                        </div>
                    </div>
                    <div class="card-body">
                        <div class="table-container">
                            <table class="table table-striped">
                                <thead>
                                    <tr>
                                        <th>ID</th>
                                        <th>用户名</th>
                                        <th>邮箱</th>
                                        <th>电话</th>
                                        <th>状态</th>
                                        <th>创建时间</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr th:each="user : ${users}">
                                        <td th:text="${user.id}"></td>
                                        <td th:text="${user.username}"></td>
                                        <td th:text="${user.email}"></td>
                                        <td th:text="${user.phone}"></td>
                                        <td>
                                            <span class="badge" th:classappend="${user.status == 1 ? 'bg-success' : 'bg-danger'}">
                                                <span th:text="${user.status == 1 ? '启用' : '禁用'}"></span>
                                            </span>
                                        </td>
                                        <td th:text="${user.createTime}"></td>
                                        <td>
                                            <div class="btn-group">
                                                <a th:href="@{/user-management/edit/{id}(id=${user.id})}" class="btn btn-sm btn-primary">编辑</a>
                                                <a th:href="@{/user-management/toggle-status/{id}(id=${user.id})}" class="btn btn-sm btn-warning" th:text="${user.status == 1 ? '禁用' : '启用'}"></a>
                                                <a th:href="@{/user-management/delete/{id}(id=${user.id})}" class="btn btn-sm btn-danger" onclick="return confirm('确定要删除该用户吗？');">删除</a>
                                            </div>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </main>

    <footer class="footer bg-light">
        <div class="container text-center">
            <span class="text-muted">Spring Boot 3.x + MyBatis Plus 示例 &copy; 2024</span>
        </div>
    </footer>
</body>
</html>